package model.entity.product;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "ProductDetails")
public class ProductDetails {

	private ProductDetailsId id;
	private Sizes sizes;
	private Color color;
	private Product product;
	private String detailImage;

	public ProductDetails() {
	}

	public ProductDetails(ProductDetailsId id, Sizes sizes, Color color,
			Product product) {
		this.id = id;
		this.sizes = sizes;
		this.color = color;
		this.product = product;
	}

	public ProductDetails(ProductDetailsId id, Sizes sizes, Color color,
			Product product, String detailImage) {
		this.id = id;
		this.sizes = sizes;
		this.color = color;
		this.product = product;
		this.detailImage = detailImage;
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "colorId", column = @Column(name = "ColorID", nullable = false)),
			@AttributeOverride(name = "sizeId", column = @Column(name = "SizeID", nullable = false)),
			@AttributeOverride(name = "productId", column = @Column(name = "ProductID", nullable = false)) })
	public ProductDetailsId getId() {
		return this.id;
	}

	public void setId(ProductDetailsId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "SizeID", nullable = false, insertable = false, updatable = false)
	public Sizes getSizes() {
		return this.sizes;
	}

	public void setSizes(Sizes sizes) {
		this.sizes = sizes;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ColorID", nullable = false, insertable = false, updatable = false)
	public Color getColor() {
		return this.color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ProductID", nullable = false, insertable = false, updatable = false)
	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@Column(name = "DetailImage")
	public String getDetailImage() {
		return this.detailImage;
	}

	public void setDetailImage(String detailImage) {
		this.detailImage = detailImage;
	}

}
